package com.photo.system.service.impl;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.photo.system.common.ErrorCode;
import com.photo.system.exception.BusinessException;
import com.photo.system.mapper.ThingFavourMapper;
import com.photo.system.model.dto.favour.FavourQueryRequest;
import com.photo.system.model.entity.ThingFavour;
import com.photo.system.model.vo.ThingFavourVO;
import com.photo.system.service.ThingFavourService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
* @author xuwenhui
* @description 针对表【thing_favour(摄影作品收藏)】的数据库操作Service实现
* @createDate 2024-11-21 21:17:09
*/
@Service
@Slf4j
public class ThingFavourServiceImpl extends ServiceImpl<ThingFavourMapper, ThingFavour>
    implements ThingFavourService {

    @Resource
    private ThingFavourMapper thingFavourMapper;

    @Override
    public Page<ThingFavourVO> getAllFavour(Page<ThingFavourVO> pageParam, FavourQueryRequest favourQueryRequest, Long userId) {
        // 自定义分页查询
        List<ThingFavourVO> bookBorrowVOS = thingFavourMapper.getAllFavour(pageParam, favourQueryRequest, userId);
        if (bookBorrowVOS == null) {
            throw new BusinessException(ErrorCode.SYSTEM_ERROR, "查询失败");
        }
        // 设置分页结果
        pageParam.setRecords(bookBorrowVOS);
        return pageParam;
    }
}




